<?php

class Factorypattern
{

	public function GetEstablishment($type){
		
		//conditions
		$model = new Establishments;
		$model->generalinformation = new Generalinformation;
		
		$model->buildingconstruction = new Buildingconstruction;
		$model->exitdetail = new Exitdetails;
		$model->meansofegress = new Meansofegress;
		$model->sectionaloccupancy = new Sectionaloccupancy;
		
		$model->verticalexit = new Verticalexits;
		$model->horizontalexit = new Horizontalexits;
		$model->ramp = new Ramps;
		$model->areaofsaferefuge = new Areaofsaferefuge;
		
		$model->emergencylight = new Emergencylights;
		$model->exitsign = new Exitsigns;
		$model->warningsafetysign = new Warningsafetysigns;
		
		$model->protectionofverticalopening = new Protectionofverticalopenings;
		$model->alarmsystem = new Alarmsystem;
		$model->standpipe = new Standpipe;
		$model->firstaidfireprotection = new Firstaidfireprotection;
		$model->automaticfiresuppression = new Automaticfiresuppression;
		$model->buildingserviceequipment = new Buildingserviceequipment;
		$model->hazardousarea = new Hazardousareas;
		$model->operatingfeature = new Operatingfeatures;
		
		return $model;
	}
	
	public static function IsVisible($establishment, $tableName, $fieldName){
		
		$model = Lookuptable::model()->find('EstablishmentType_Id=:param and
											TableName=:param1 and
											FieldName=:param2'
											,array('param'=>$establishment,
												   'param1'=>$tableName,
												   'param2'=>$fieldName));
												   
		if($model != null){
			return $model->Value;
		}else{
			return 0;
		}
	}
}

?>